package model

import (
	"time"

	"gorm.io/gorm"
)

// Project 筹款项目模型
type Project struct {
	ID            uint64  `gorm:"primaryKey"`
	UserID        uint64  `gorm:"not null;index"`
	Title         string  `gorm:"type:varchar(100);not null"`
	CategoryID    uint    `gorm:"not null;index"`
	TargetAmount  float64 `gorm:"type:decimal(12,2);not null"`
	CurrentAmount float64 `gorm:"type:decimal(12,2);default:0"`
	Description   string  `gorm:"type:text;not null"`
	Images        string  `gorm:"type:json"`
	Status        int8    `gorm:"type:tinyint;default:0;index"`
	EndTime       *time.Time
	CreatedAt     time.Time      `gorm:"autoCreateTime"`
	UpdatedAt     time.Time      `gorm:"autoUpdateTime"`
	DeletedAt     gorm.DeletedAt `gorm:"index"`

	// 关联
	User     User     `gorm:"foreignKey:UserID"`
	Category Category `gorm:"foreignKey:CategoryID"`
}

// ProjectDocument 项目文档模型
type ProjectDocument struct {
	ID        uint64 `gorm:"primaryKey"`
	ProjectID uint64 `gorm:"not null;index"`
	Type      int8   `gorm:"type:tinyint;not null"`
	FileURL   string `gorm:"type:varchar(255);not null"`
	Status    int8   `gorm:"type:tinyint;default:0;index"`
}

// ProjectUpdate 项目动态模型
type ProjectUpdate struct {
	ID        uint64 `gorm:"primaryKey"`
	ProjectID uint64 `gorm:"not null;index"`
	Content   string `gorm:"type:text;not null"`
	Images    string `gorm:"type:json"`
}
